package com.hex.ds.hdrs.period.task.service;

import com.hex.ds.hdrs.common.utils.BaseUtil;
import com.hex.ds.hdrs.common.utils.HdrsDateUtil;
import com.hex.ds.hdrs.period.task.dao.PeriodTaskStreamDao;
import com.hex.ds.hdrs.period.task.dto.PeriodTaskStreamDto;
import com.hex.ds.hdrs.period.task.po.PeriodTaskStream;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @Package: com.hex.ds.hdrs.period.task.service
 * @ClassName PeriodTaskStreamService
 * @Description:
 * @Author: 任务执行完记录操作<gc.zuo>
 * @Date 2021/7/14 11:28
 * @Version v1.0
 **/
@Slf4j
@Service
public class PeriodTaskStreamService {

    @Autowired
    private PeriodTaskStreamDao periodTaskStreamDao;

    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public void insert(Map map) {
        String curDate = HdrsDateUtil.getCurTs();
        map.put("streamType", "1");
        map.put("streamTs", curDate);
        map.put("crtTs", curDate);
        map.put("upTs", curDate);
        map.put("pkId",BaseUtil.getPkId());
        this.periodTaskStreamDao.insert(map);
    }

    /**
     * @Method: selectPage
     * @Param: [periodTaskStreamDto, page]
     * @Return: java.lang.Object
     * @Description: 周期任务实例流水数据分页查询
     * @Author: ji.tang
     * @Date: 2022/6/20 11:03
     * @Version: V1.0
     */
    public List<PeriodTaskStream> selectList(PeriodTaskStreamDto periodTaskStreamDto) {
        return this.periodTaskStreamDao.selectList(periodTaskStreamDto);
    }
}
